/*
 * @Description:管理
 * @Author: maskMan
 * @LastEditTime: 2024-11-21 09:24:44
 */

import Config from '@/utils/config';
import Mock from '@/api/mock';
import request from '@/api/request';
/**更新管理信息 */
export const updateManageData = async function (data: Obj = null): Promise<TRet.Bool> {
  if (Config.env == 'Test') {
    return Mock.mock_update_manage_data();
  }
  const res = await request.patch<TRet.Bool>('admin/updateManageData', data);
  return res;
};
/**获取统计信息 */
export const getCounts = async function (data: Obj = null): Promise<TRet.Counts> {
  if (Config.env == 'Test') {
    return Mock.mock_get_counts();
  }
  const res = await request.get<TRet.Counts>('admin/getCounts', data);
  return res;
};
/**获取代理列表*/
export const getAgentList = async function (data: Obj = null): Promise<TRet.AgentList> {
  if (Config.env == 'Test') {
    return Mock.mock_get_agent_list();
  }
  const res = await request.get<TRet.AgentList>('admin/getAgentList', data);
  return res;
};
/**创建代理*/
export const createAgent = async function (data: TReq.AgentCreat = null): Promise<TRet.AgentType> {
  if (Config.env == 'Test') {
    return Mock.mock_create_agent(data);
  }
  const res = await request.get<TRet.AgentType>('admin/createAgent', data);
  return res;
};
/**编辑代理信息*/
export const updateAgent = async function (data: TReq.AgentCreat = null): Promise<TRet.AgentType> {
  if (Config.env == 'Test') {
    return Mock.mock_update_agent(data);
  }
  const res = await request.get<TRet.AgentType>('admin/updateAgent', data);
  return res;
};
/**更新代理状态*/
export const updateAgentStatus = async function (data: boolean): Promise<TRet.Bool> {
  if (Config.env == 'Test') {
    return Mock.mock_update_agent_status(data);
  }
  const res = await request.get<TRet.Bool>('admin/updateAgentStatus', { data });
  return res;
};
/**更新代理状态*/
export const deleteAgent = async function (account: string): Promise<TRet.Bool> {
  if (Config.env == 'Test') {
    return Mock.mock_delete_agent(account);
  }
  const res = await request.get<TRet.Bool>('admin/deleteAgent', { account });
  return res;
};
